
<!DOCTYPE html>
<html lang="zh-Hans" class="loading">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>Windows批处理(cmd/bat)常用命令小结 - MonianHello - Blog</title>
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="google" content="notranslate" />
    <meta name="keywords" content="MonianHello,"> 
    <meta name="description" content="前言批处理文件（batch file）包含一系列 DOS命令，通常用于自动执行重复性任务。用户只需双击批处理文件便可执行任务，而无需重复输入相同指令。编写批处理文件非常简单，但难点在于确保一切按顺序,"> 
    <meta name="author" content="MonianHello"> 
    <link rel="alternative" href="atom.xml" title="MonianHello - Blog" type="application/atom+xml"> 
    <link rel="icon" href="/img/favicon.png"> 
    
    
<link rel="stylesheet" href="/css/diaspora.css">

	<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({
              google_ad_client: "ca-pub-8691406134231910",
              enable_page_level_ads: true
         });
    </script>
    <script async custom-element="amp-auto-ads"
        src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
    </script>
<meta name="generator" content="Hexo 5.2.0"></head>

<body class="loading">
    <span id="config-title" style="display:none">MonianHello - Blog</span>
    <div id="loader"></div>
    <div id="single">
    <div id="top" style="display: block;">
    <div class="bar" style="width: 0;"></div>
    <a class="iconfont icon-home image-icon" href="javascript:;" data-url="http://monianhello.github.io"></a>
    <div title="播放/暂停" class="iconfont icon-play"></div>
    <h3 class="subtitle">Windows批处理(cmd/bat)常用命令小结</h3>
    <div class="social">
        <div>
            <div class="share">
                <a title="获取二维码" class="iconfont icon-scan" href="javascript:;"></a>
            </div>
            <div id="qr"></div>
        </div>
    </div>
    <div class="scrollbar"></div>
</div>

    <div class="section">
        <div class="article">
    <div class='main'>
        <h1 class="title">Windows批处理(cmd/bat)常用命令小结</h1>
        <div class="stuff">
            <span>十一月 24, 2020</span>
            
  <ul class="post-tags-list" itemprop="keywords"><li class="post-tags-list-item"><a class="post-tags-list-link" href="/tags/%E5%AD%A6%E4%B9%A0/" rel="tag">学习</a></li><li class="post-tags-list-item"><a class="post-tags-list-link" href="/tags/%E6%89%B9%E5%A4%84%E7%90%86/" rel="tag">批处理</a></li></ul>


        </div>
        <div class="content markdown">
            <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>批处理文件（batch file）包含一系列 DOS命令，通常用于自动执行重复性任务。用户只需双击批处理文件便可执行任务，而无需重复输入相同指令。编写批处理文件非常简单，但难点在于确保一切按顺序执行。编写严谨的批处理文件可以极大程度地节省时间，在应对重复性工作时尤其有效。</p>
<blockquote>
<p>在Windows中善用批处理可以简化很多重复工作</p>
</blockquote>
<h2 id="更新记录"><a href="#更新记录" class="headerlink" title="更新记录"></a>更新记录</h2><p>2016年03月29日 - 初稿<br>Windows批处理(cmd/bat)常用命令小结</p>
<h2 id="什么是批处理"><a href="#什么是批处理" class="headerlink" title="什么是批处理"></a>什么是批处理</h2><p>批处理(Batch)，也称为批处理脚本。顾名思义，批处理就是对某对象进行批量的处理。批处理文件的扩展名为bat。<br>目前比较常见 的批处理包含两类：DOS批处理和PS批处理。PS批处理是基于强大的图片编辑软件Photoshop的，用来批量处理图片的脚本；而DOS批处理则是基于DOS命令的，用来自动地批量地执行DOS命令以实现特定操作的脚本。这里要讲的就是DOS批处理。<br>批处理是一种简化的脚本语言，它应用于DOS和Windows系统中，它是由DOS或者Windows系统内嵌的命令解释器（通常是COMMAND.COM或者CMD.EXE）解释运行。类似于Unix中的Shell脚本。批处理文件具有.bat或者.cmd的扩展名，其最简单的例子，是逐行书写在命令行中会用到的各种命令。更复杂的情况，需要使用if，for，goto等命令控制程序的运行过程，如同C，Basic等中高级语言一样。如果需要实现更复杂的应用，利用外部程序是必要的，这包括系统本身提供的外部命令和第三方提供的工具或者软件。<br>批处理文件，或称为批处理程序，是由一条条的DOS命令组成的普通文本文件，可以用记事本直接编辑或用DOS命令创建，也可以用DOS下的文本编辑器Edit.exe来编辑。在“命令提示”下键入批处理文件的名称，或者双击该批处理文件，系统就会调用Cmd.exe运行该批处理程序。一般情况下，每条命令占据一行；当然也可以将多条命令用特定符号（如：&amp;、&amp;&amp;、|、||等）分隔后写入同一行中；还有的情况就是像if、for等较高级的命令则要占据几行甚至几十几百行的空间。<br>系统在解释运行批处理程序时，首先扫描整个批处理程序，然后从第一行代码开始向下逐句执行所有的命令，直至程序结尾或遇见exit命令或出错意外退出。</p>
<h2 id="批处理命令简介"><a href="#批处理命令简介" class="headerlink" title="批处理命令简介"></a>批处理命令简介</h2><ul>
<li>echo</li>
<li>rem</li>
<li>pause</li>
<li>call</li>
<li>start</li>
<li>goto</li>
<li>set<br>批处理常用命令总结<h2 id="批处理符号简介"><a href="#批处理符号简介" class="headerlink" title="批处理符号简介"></a>批处理符号简介</h2></li>
<li>回显屏蔽 @</li>
<li>重定向1 &gt;与&gt;&gt;</li>
<li>重定向2 &lt;</li>
<li>管道符号 |</li>
<li>转义符 ^</li>
<li>逻辑命令符包括：&amp;、&amp;&amp;、||<br>批处理常用命令总结<h2 id="常用DOS命令"><a href="#常用DOS命令" class="headerlink" title="常用DOS命令"></a>常用DOS命令</h2></li>
</ul>
<p><strong>文件夹管理</strong></p>
<ul>
<li>cd 显示当前目录名或改变当前目录。</li>
<li>md 创建目录。</li>
<li>rd 删除一个目录。</li>
<li>dir 显示目录中的文件和子目录列表。</li>
<li>tree 以图形显示驱动器或路径的文件夹结构。</li>
<li>path 为可执行文件显示或设置一个搜索路径。</li>
<li>xcopy 复制文件和目录树。</li>
</ul>
<p><strong>文件管理</strong></p>
<ul>
<li>type 显示文本文件的内容。</li>
<li>copy 将一份或多份文件复制到另一个位置。</li>
<li>del 删除一个或数个文件。</li>
<li>move 移动文件并重命名文件和目录。(Windows XP Home Edition中没有)</li>
<li>ren 重命名文件。</li>
<li>replace 替换文件。</li>
<li>attrib 显示或更改文件属性。</li>
<li>find 搜索字符串。</li>
<li>fc 比较两个文件或两个文件集并显示它们之间的不同</li>
</ul>
<p><strong>网络命令</strong></p>
<ul>
<li>ping 进行网络连接测试、名称解析</li>
<li>ftp 文件传输</li>
<li>net 网络命令集及用户管理</li>
<li>telnet 远程登陆</li>
<li>ipconfig显示、修改TCP/IP设置</li>
<li>msg 给用户发送消息</li>
<li>arp 显示、修改局域网的IP地址-物理地址映射列表</li>
</ul>
<p><strong>系统管理</strong></p>
<ul>
<li>at 安排在特定日期和时间运行命令和程序</li>
<li>shutdown立即或定时关机或重启</li>
<li>tskill 结束进程</li>
<li>taskkill结束进程(比tskill高级，但WinXPHome版中无该命令)</li>
<li>tasklist显示进程列表(Windows XP Home Edition中没有)</li>
<li>sc 系统服务设置与控制</li>
<li>reg 注册表控制台工具</li>
<li>powercfg控制系统上的电源设置<blockquote>
<p>对于以上列出的所有命令，在cmd中输入命令+/?即可查看该命令的帮助信息。如find /?</p>
</blockquote>
<h2 id="Windows-Batch-常用命令"><a href="#Windows-Batch-常用命令" class="headerlink" title="Windows Batch 常用命令"></a>Windows Batch 常用命令</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br></pre></td><td class="code"><pre><span class="line">1 <span class="built_in">echo</span> 和 @</span><br><span class="line">回显命令</span><br><span class="line">@ <span class="comment">#关闭单行回显</span></span><br><span class="line"><span class="built_in">echo</span> off <span class="comment">#从下一行开始关闭回显</span></span><br><span class="line">@<span class="built_in">echo</span> off <span class="comment">#从本行开始关闭回显。一般批处理第一行都是这个</span></span><br><span class="line"><span class="built_in">echo</span> on <span class="comment">#从下一行开始打开回显</span></span><br><span class="line"><span class="built_in">echo</span> <span class="comment">#显示当前是 echo off 状态还是 echo on 状态</span></span><br><span class="line"><span class="built_in">echo</span>. <span class="comment">#输出一个”回车换行”，空白行</span></span><br><span class="line"><span class="comment">#(同echo, echo; echo+ echo[ echo] echo/ echo)</span></span><br><span class="line">2 errorlevel</span><br><span class="line"><span class="built_in">echo</span> %errorlevel%</span><br><span class="line">每个命令运行结束，可以用这个命令行格式查看返回码</span><br><span class="line">默认值为0，一般命令执行出错会设 errorlevel 为1</span><br><span class="line">3 dir</span><br><span class="line">显示文件夹内容</span><br><span class="line">dir <span class="comment">#显示当前目录中的文件和子目录</span></span><br><span class="line">dir /a <span class="comment">#显示当前目录中的文件和子目录，包括隐藏文件和系统文件</span></span><br><span class="line">dir c: /a:d <span class="comment">#显示 C 盘当前目录中的目录</span></span><br><span class="line">dir c: /a:-d <span class="comment">#显示 C 盘根目录中的文件</span></span><br><span class="line">dir c: /b/p <span class="comment">#/b只显示文件名，/p分页显示</span></span><br><span class="line">dir *.exe /s <span class="comment">#显示当前目录和子目录里所有的.exe文件</span></span><br><span class="line">4 <span class="built_in">cd</span></span><br><span class="line">切换目录</span><br><span class="line"><span class="built_in">cd</span> <span class="comment">#进入根目录</span></span><br><span class="line"><span class="built_in">cd</span> <span class="comment">#显示当前目录</span></span><br><span class="line"><span class="built_in">cd</span> /d d:sdk <span class="comment">#可以同时更改盘符和目录</span></span><br><span class="line">5 md</span><br><span class="line">创建目录</span><br><span class="line">md d:abc <span class="comment">#如果 d:a 不存在，将会自动创建中级目录</span></span><br><span class="line"><span class="comment">#如果命令扩展名被停用，则需要键入 mkdir abc。</span></span><br><span class="line">6 rd</span><br><span class="line">删除目录</span><br><span class="line">rd abc <span class="comment">#删除当前目录里的 abc 子目录，要求为空目录</span></span><br><span class="line">rd /s/q d:temp <span class="comment">#删除 d:temp 文件夹及其子文件夹和文件，/q安静模式</span></span><br><span class="line">7 del</span><br><span class="line">删除文件</span><br><span class="line">del d:test.txt <span class="comment">#删除指定文件，不能是隐藏、系统、只读文件</span></span><br><span class="line">del /q/a/f d:temp*.*</span><br><span class="line">删除 d:temp 文件夹里面的所有文件，包括隐藏、只读、系统文件，不包括子目录</span><br><span class="line">del /q/a/f/s d:temp*.*</span><br><span class="line">删除 d:temp 及子文件夹里面的所有文件，包括隐藏、只读、系统文件，不包括子目录</span><br><span class="line">8 ren</span><br><span class="line">重命名命令</span><br><span class="line">ren d:temp tmp <span class="comment">#支持对文件夹的重命名</span></span><br><span class="line">9 cls</span><br><span class="line">清屏</span><br><span class="line">10 <span class="built_in">type</span></span><br><span class="line">显示文件内容</span><br><span class="line"><span class="built_in">type</span> c:boot.ini <span class="comment">#显示指定文件的内容，程序文件一般会显示乱码</span></span><br><span class="line"><span class="built_in">type</span> *.txt <span class="comment">#显示当前目录里所有.txt文件的内容</span></span><br><span class="line">11 copy</span><br><span class="line">拷贝文件</span><br><span class="line">copy c:test.txt d:test.bak</span><br><span class="line">复制 c:test.txt 文件到 d: ，并重命名为 test.bak</span><br><span class="line">copy con test.txt</span><br><span class="line">从屏幕上等待输入，按 Ctrl+Z 结束输入，输入内容存为test.txt文件</span><br><span class="line">con代表屏幕，prn代表打印机，nul代表空设备</span><br><span class="line">copy 1.txt + 2.txt 3.txt</span><br><span class="line">合并 1.txt 和 2.txt 的内容，保存为 3.txt 文件</span><br><span class="line">如果不指定 3.txt ，则保存到 1.txt</span><br><span class="line">copy test.txt +</span><br><span class="line">复制文件到自己，实际上是修改了文件日期</span><br><span class="line">12 title</span><br><span class="line">设置cmd窗口的标题</span><br><span class="line">title 新标题 <span class="comment">#可以看到cmd窗口的标题栏变了</span></span><br><span class="line">13 ver</span><br><span class="line">显示系统版本</span><br><span class="line">14 label 和 vol</span><br><span class="line">设置卷标</span><br><span class="line">vol <span class="comment">#显示卷标</span></span><br><span class="line">label <span class="comment">#显示卷标，同时提示输入新卷标</span></span><br><span class="line">label c:system <span class="comment">#设置C盘的卷标为 system</span></span><br><span class="line">15 pause</span><br><span class="line">暂停命令</span><br><span class="line">16 rem 和 ::</span><br><span class="line">注释命令</span><br><span class="line">注释行不执行操作</span><br><span class="line">17 date 和 time</span><br><span class="line">日期和时间</span><br><span class="line">date <span class="comment">#显示当前日期，并提示输入新日期，按&quot;回车&quot;略过输入</span></span><br><span class="line">date/t <span class="comment">#只显示当前日期，不提示输入新日期</span></span><br><span class="line">time <span class="comment">#显示当前时间，并提示输入新时间，按&quot;回车&quot;略过输入</span></span><br><span class="line">time/t <span class="comment">#只显示当前时间，不提示输入新时间</span></span><br><span class="line">18 goto 和 :</span><br><span class="line">跳转命令</span><br><span class="line">:label <span class="comment">#行首为:表示该行是标签行，标签行不执行操作</span></span><br><span class="line">goto label <span class="comment">#跳转到指定的标签那一行</span></span><br><span class="line">19 find (外部命令)</span><br><span class="line">查找命令</span><br><span class="line">find <span class="string">&quot;abc&quot;</span> c:test.txt</span><br><span class="line">在 c:test.txt 文件里查找含 abc 字符串的行</span><br><span class="line">如果找不到，将设 errorlevel 返回码为1</span><br><span class="line">find /i “abc” c:test.txt</span><br><span class="line">查找含 abc 的行，忽略大小写</span><br><span class="line">find /c <span class="string">&quot;abc&quot;</span> c:test.txt</span><br><span class="line">显示含 abc 的行的行数</span><br><span class="line">20 more (外部命令)</span><br><span class="line">逐屏显示</span><br><span class="line">more c:test.txt <span class="comment">#逐屏显示 c:test.txt 的文件内容</span></span><br><span class="line">21 tree</span><br><span class="line">显示目录结构</span><br><span class="line">tree d: <span class="comment">#显示D盘的文件目录结构</span></span><br><span class="line">22 &amp;</span><br><span class="line">顺序执行多条命令，而不管命令是否执行成功</span><br><span class="line">23 &amp;&amp;</span><br><span class="line">顺序执行多条命令，当碰到执行出错的命令后将不执行后面的命令</span><br><span class="line">find <span class="string">&quot;ok&quot;</span> c:test.txt &amp;&amp; <span class="built_in">echo</span> 成功</span><br><span class="line">如果找到了<span class="string">&quot;ok&quot;</span>字样，就显示<span class="string">&quot;成功&quot;</span>，找不到就不显示</span><br><span class="line">24 ||</span><br><span class="line">顺序执行多条命令，当碰到执行正确的命令后将不执行后面的命令</span><br><span class="line">find <span class="string">&quot;ok&quot;</span> c:test.txt || <span class="built_in">echo</span> 不成功</span><br><span class="line">如果找不到<span class="string">&quot;ok&quot;</span>字样，就显示<span class="string">&quot;不成功&quot;</span>，找到了就不显示</span><br><span class="line">25 |</span><br><span class="line">管道命令</span><br><span class="line">dir *.* /s/a | find /c <span class="string">&quot;.exe&quot;</span></span><br><span class="line">管道命令表示先执行 dir 命令，对其输出的结果执行后面的 find 命令</span><br><span class="line">该命令行结果：输出当前文件夹及所有子文件夹里的.exe文件的个数</span><br><span class="line"><span class="built_in">type</span> c:test.txt|more</span><br><span class="line">这个和 more c:test.txt 的效果是一样的</span><br><span class="line">26 &gt; 和 &gt;&gt;</span><br><span class="line">输出重定向命令</span><br><span class="line">&gt; 清除文件中原有的内容后再写入</span><br><span class="line">&gt;&gt; 追加内容到文件末尾，而不会清除原有的内容</span><br><span class="line">主要将本来显示在屏幕上的内容输出到指定文件中</span><br><span class="line">指定文件如果不存在，则自动生成该文件</span><br><span class="line"><span class="built_in">type</span> c:test.txt &gt;prn</span><br><span class="line">屏幕上不显示文件内容，转向输出到打印机</span><br><span class="line"><span class="built_in">echo</span> hello world&gt;con</span><br><span class="line">在屏幕上显示hello world，实际上所有输出都是默认 &gt;con 的</span><br><span class="line">copy c:test.txt f: &gt;nul</span><br><span class="line">拷贝文件，并且不显示<span class="string">&quot;文件复制成功&quot;</span>的提示信息，但如果f盘不存在，还是会显示出错信息</span><br><span class="line">copy c:test.txt f: &gt;nul 2&gt;nul</span><br><span class="line">不显示”文件复制成功”的提示信息，并且f盘不存在的话，也不显示错误提示信息</span><br><span class="line"><span class="built_in">echo</span> ^^W ^&gt; ^W&gt;c:test.txt</span><br><span class="line">生成的文件内容为 ^W &gt; W</span><br><span class="line">^ 和 &gt; 是控制命令，要把它们输出到文件，必须在前面加个 ^ 符号</span><br><span class="line">27 &lt;</span><br><span class="line">从文件中获得输入信息，而不是从屏幕上</span><br><span class="line">一般用于 date time label 等需要等待输入的命令</span><br><span class="line">@<span class="built_in">echo</span> off</span><br><span class="line"><span class="built_in">echo</span> 2005-05-01&gt;temp.txt</span><br><span class="line">date &lt;temp.txt</span><br><span class="line">del temp.txt</span><br><span class="line">这样就可以不等待输入直接修改当前日期</span><br><span class="line">28 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 %*</span><br><span class="line">命令行传递给批处理的参数</span><br><span class="line">%0 批处理文件本身</span><br><span class="line">%1 第一个参数</span><br><span class="line">%9 第九个参数</span><br><span class="line">%* 从第一个参数开始的所有参数</span><br><span class="line">批参数(%n)的替代已被增强。您可以使用以下语法:</span><br><span class="line">%~1 - 删除引号(<span class="string">&quot;)，扩充 %1</span></span><br><span class="line"><span class="string">%~f1 - 将 %1 扩充到一个完全合格的路径名</span></span><br><span class="line"><span class="string">%~d1 - 仅将 %1 扩充到一个驱动器号</span></span><br><span class="line"><span class="string">%~p1 - 仅将 %1 扩充到一个路径</span></span><br><span class="line"><span class="string">%~n1 - 仅将 %1 扩充到一个文件名</span></span><br><span class="line"><span class="string">%~x1 - 仅将 %1 扩充到一个文件扩展名</span></span><br><span class="line"><span class="string">%~s1 - 扩充的路径指含有短名</span></span><br><span class="line"><span class="string">%~a1 - 将 %1 扩充到文件属性</span></span><br><span class="line"><span class="string">%~t1 - 将 %1 扩充到文件的日期/时间</span></span><br><span class="line"><span class="string">%~z1 - 将 %1 扩充到文件的大小</span></span><br><span class="line"><span class="string">%~<span class="variable">$PATH</span> : 1 - 查找列在 PATH 环境变量的目录，并将 %1</span></span><br><span class="line"><span class="string">扩充到找到的第一个完全合格的名称。如果环境</span></span><br><span class="line"><span class="string">变量名未被定义，或者没有找到文件，此组合键会</span></span><br><span class="line"><span class="string">扩充到空字符串</span></span><br><span class="line"><span class="string">可以组合修定符来取得多重结果:</span></span><br><span class="line"><span class="string">%~dp1 - 只将 %1 扩展到驱动器号和路径</span></span><br><span class="line"><span class="string">%~nx1 - 只将 %1 扩展到文件名和扩展名</span></span><br><span class="line"><span class="string">%~dp<span class="variable">$PATH</span>:1 - 在列在 PATH 环境变量中的目录里查找 %1，</span></span><br><span class="line"><span class="string">并扩展到找到的第一个文件的驱动器号和路径。</span></span><br><span class="line"><span class="string">%~ftza1 - 将 %1 扩展到类似 DIR 的输出行。</span></span><br><span class="line"><span class="string">可以参照 call/? 或 for/? 看出每个参数的含意</span></span><br><span class="line"><span class="string">echo load &quot;</span>%%1<span class="string">&quot; &quot;</span>%%2<span class="string">&quot;&gt;c:test.txt</span></span><br><span class="line"><span class="string">生成的文件内容为 load &quot;</span>%1<span class="string">&quot; &quot;</span>%2<span class="string">&quot;</span></span><br><span class="line"><span class="string">批处理文件里，用这个格式把命令行参数输出到文件</span></span><br><span class="line"><span class="string">29 if</span></span><br><span class="line"><span class="string">判断命令</span></span><br><span class="line"><span class="string">if &quot;</span>%1<span class="string">&quot;==&quot;</span>/a<span class="string">&quot; echo 第一个参数是/a</span></span><br><span class="line"><span class="string">if /i &quot;</span>%1<span class="string">&quot; equ &quot;</span>/a<span class="string">&quot; echo 第一个参数是/a</span></span><br><span class="line"><span class="string">/i 表示不区分大小写，equ 和 == 是一样的，其它运算符参见 if/?</span></span><br><span class="line"><span class="string">if exist c:test.bat echo 存在c:test.bat文件</span></span><br><span class="line"><span class="string">if not exist c:windows (</span></span><br><span class="line"><span class="string">echo 不存在c:windows文件夹</span></span><br><span class="line"><span class="string">)</span></span><br><span class="line"><span class="string">if exist c:test.bat (</span></span><br><span class="line"><span class="string">echo 存在c:test.bat</span></span><br><span class="line"><span class="string">) else (</span></span><br><span class="line"><span class="string">echo 不存在c:test.bat</span></span><br><span class="line"><span class="string">)</span></span><br><span class="line"><span class="string">30 setlocal 和 endlocal</span></span><br><span class="line"><span class="string">设置”命令扩展名”和”延缓环境变量扩充”</span></span><br><span class="line"><span class="string">SETLOCAL ENABLEEXTENSIONS #启用&quot;</span>命令扩展名<span class="string">&quot;</span></span><br><span class="line"><span class="string">SETLOCAL DISABLEEXTENSIONS #停用&quot;</span>命令扩展名<span class="string">&quot;</span></span><br><span class="line"><span class="string">SETLOCAL ENABLEDELAYEDEXPANSION #启用&quot;</span>延缓环境变量扩充<span class="string">&quot;</span></span><br><span class="line"><span class="string">SETLOCAL DISABLEDELAYEDEXPANSION #停用&quot;</span>延缓环境变量扩充<span class="string">&quot;</span></span><br><span class="line"><span class="string">ENDLOCAL #恢复到使用SETLOCAL语句以前的状态</span></span><br><span class="line"><span class="string">“命令扩展名”默认为启用</span></span><br><span class="line"><span class="string">“延缓环境变量扩充”默认为停用</span></span><br><span class="line"><span class="string">批处理结束系统会自动恢复默认值</span></span><br><span class="line"><span class="string">可以修改注册表以禁用&quot;</span>命令扩展名<span class="string">&quot;，详见 cmd /? 。所以用到&quot;</span>命令扩展名<span class="string">&quot;的程</span></span><br><span class="line"><span class="string">序，建议在开头和结尾加上 SETLOCAL ENABLEEXTENSIONS 和 ENDLOCAL 语句，以确</span></span><br><span class="line"><span class="string">保程序能在其它系统上正确运行</span></span><br><span class="line"><span class="string">&quot;</span>延缓环境变量扩充<span class="string">&quot;主要用于 if 和 for 的符合语句，在 set 的说明里有其实用例程</span></span><br><span class="line"><span class="string">31 set</span></span><br><span class="line"><span class="string">设置变量</span></span><br><span class="line"><span class="string">引用变量可在变量名前后加 % ，即 %变量名%</span></span><br><span class="line"><span class="string">set #显示目前所有可用的变量，包括系统变量和自定义的变量</span></span><br><span class="line"><span class="string">echo %SystemDrive% #显示系统盘盘符。系统变量可以直接引用</span></span><br><span class="line"><span class="string">set p #显示所有以p开头的变量，要是一个也没有就设errorlevel=1</span></span><br><span class="line"><span class="string">set p=aa1bb1aa2bb2 #设置变量p，并赋值为 = 后面的字符串，即aa1bb1aa2bb2</span></span><br><span class="line"><span class="string">echo %p% #显示变量p代表的字符串，即aa1bb1aa2bb2</span></span><br><span class="line"><span class="string">echo %p:~6% #显示变量p中第6个字符以后的所有字符，即aa2bb2</span></span><br><span class="line"><span class="string">echo %p:~6,3% #显示第6个字符以后的3个字符，即aa2</span></span><br><span class="line"><span class="string">echo %p:~0,3% #显示前3个字符，即aa1</span></span><br><span class="line"><span class="string">echo %p:~-2% #显示最后面的2个字符，即b2</span></span><br><span class="line"><span class="string">echo %p:~0,-2% #显示除了最后2个字符以外的其它字符，即aa1bb1aa2b</span></span><br><span class="line"><span class="string">echo %p:aa=c% #用c替换变量p中所有的aa，即显示c1bb1c2bb2</span></span><br><span class="line"><span class="string">echo %p:aa=% #将变量p中的所有aa字符串置换为空，即显示1bb12bb2</span></span><br><span class="line"><span class="string">echo %p:*bb=c% #第一个bb及其之前的所有字符被替换为c，即显示c1aa2bb2</span></span><br><span class="line"><span class="string">set p=%p:*bb=c% #设置变量p，赋值为 %p:*bb=c% ，即c1aa2bb2</span></span><br><span class="line"><span class="string">set /a p=39 #设置p为数值型变量，值为39</span></span><br><span class="line"><span class="string">set /a p=39/10 #支持运算符，有小数时用去尾法，39/10=3.9，去尾得3，p=3</span></span><br><span class="line"><span class="string">set /a p=p/10 #用 /a 参数时，在 = 后面的变量可以不加%直接引用</span></span><br><span class="line"><span class="string">set /a p=”1&amp;0″ #”与”运算，要加引号。其它支持的运算符参见set/?</span></span><br><span class="line"><span class="string">set p= #取消p变量</span></span><br><span class="line"><span class="string">set /p p=请输入</span></span><br><span class="line"><span class="string">屏幕上显示”请输入”，并会将输入的字符串赋值给变量p</span></span><br><span class="line"><span class="string">注意这条可以用来取代 choice 命令</span></span><br><span class="line"><span class="string">注意变量在 if 和 for 的复合语句里是一次性全部替换的，如</span></span><br><span class="line"><span class="string">@echo off</span></span><br><span class="line"><span class="string">set p=aaa</span></span><br><span class="line"><span class="string">if %p%==aaa (</span></span><br><span class="line"><span class="string">echo %p%</span></span><br><span class="line"><span class="string">set p=bbb</span></span><br><span class="line"><span class="string">echo %p%</span></span><br><span class="line"><span class="string">)</span></span><br><span class="line"><span class="string">结果将显示</span></span><br><span class="line"><span class="string">aaa</span></span><br><span class="line"><span class="string">aaa</span></span><br><span class="line"><span class="string">因为在读取 if 语句时已经将所有 %p% 替换为aaa</span></span><br><span class="line"><span class="string">这里的&quot;</span>替换<span class="string">&quot;，在 /? 帮助里就是指&quot;</span>扩充<span class="string">&quot;、&quot;</span>环境变量扩充<span class="string">&quot;</span></span><br><span class="line"><span class="string">可以启用”延缓环境变量扩充”，用 ! 来引用变量，即 !变量名!</span></span><br><span class="line"><span class="string">@echo off</span></span><br><span class="line"><span class="string">SETLOCAL ENABLEDELAYEDEXPANSION</span></span><br><span class="line"><span class="string">set p=aaa</span></span><br><span class="line"><span class="string">if %p%==aaa (</span></span><br><span class="line"><span class="string">echo %p%</span></span><br><span class="line"><span class="string">set p=bbb</span></span><br><span class="line"><span class="string">echo !p!</span></span><br><span class="line"><span class="string">)</span></span><br><span class="line"><span class="string">ENDLOCAL</span></span><br><span class="line"><span class="string">结果将显示</span></span><br><span class="line"><span class="string">aaa</span></span><br><span class="line"><span class="string">bbb</span></span><br><span class="line"><span class="string">还有几个动态变量，运行 set 看不到</span></span><br><span class="line"><span class="string">%CD% #代表当前目录的字符串</span></span><br><span class="line"><span class="string">%DATE% #当前日期</span></span><br><span class="line"><span class="string">%TIME% #当前时间</span></span><br><span class="line"><span class="string">%RANDOM% #随机整数，介于0~32767</span></span><br><span class="line"><span class="string">%ERRORLEVEL% #当前 ERRORLEVEL 值</span></span><br><span class="line"><span class="string">%CMDEXTVERSION% #当前命令处理器扩展名版本号</span></span><br><span class="line"><span class="string">%CMDCMDLINE% #调用命令处理器的原始命令行</span></span><br><span class="line"><span class="string">可以用echo命令查看每个变量值，如 echo %time%</span></span><br><span class="line"><span class="string">注意 %time% 精确到毫秒，在批处理需要延时处理时可以用到</span></span><br><span class="line"><span class="string">32 start</span></span><br><span class="line"><span class="string">批处理中调用外部程序的命令，否则等外部程序完成后才继续执行剩下的指令</span></span><br><span class="line"><span class="string">33 call</span></span><br><span class="line"><span class="string">批处理中调用另外一个批处理的命令，否则剩下的批处理指令将不会被执行</span></span><br><span class="line"><span class="string">有时有的应用程序用start调用出错的，也可以call调用</span></span><br><span class="line"><span class="string">34 choice (外部命令)</span></span><br><span class="line"><span class="string">选择命令</span></span><br><span class="line"><span class="string">让用户输入一个字符，从而选择运行不同的命令，返回码errorlevel为1234……</span></span><br><span class="line"><span class="string">win98里是http://choice.com</span></span><br><span class="line"><span class="string">win2000pro里没有，可以从win98里拷过来</span></span><br><span class="line"><span class="string">win2003里是choice.exe</span></span><br><span class="line"><span class="string">choice /N /C y /T 5 /D y&gt;nul</span></span><br><span class="line"><span class="string">延时5秒</span></span><br><span class="line"><span class="string">35 assoc 和 ftype</span></span><br><span class="line"><span class="string">文件关联</span></span><br><span class="line"><span class="string">assoc 设置&#x27;文件扩展名&#x27;关联，关联到&#x27;文件类型&#x27;</span></span><br><span class="line"><span class="string">ftype 设置&#x27;文件类型&#x27;关联，关联到&#x27;执行程序和参数&#x27;</span></span><br><span class="line"><span class="string">当你双击一个.txt文件时，windows并不是根据.txt直接判断用 notepad.exe 打开</span></span><br><span class="line"><span class="string">而是先判断.txt属于 txtfile &#x27;文件类型&#x27;</span></span><br><span class="line"><span class="string">再调用 txtfile 关联的命令行 txtfile=%SystemRoot%system32NOTEPAD.EXE %1</span></span><br><span class="line"><span class="string">可以在&quot;</span>文件夹选项<span class="string">&quot;→&quot;</span>文件类型<span class="string">&quot;里修改这2种关联</span></span><br><span class="line"><span class="string">assoc #显示所有&#x27;文件扩展名&#x27;关联</span></span><br><span class="line"><span class="string">assoc .txt #显示.txt代表的&#x27;文件类型&#x27;，结果显示 .txt=txtfile</span></span><br><span class="line"><span class="string">assoc .doc #显示.doc代表的&#x27;文件类型&#x27;，结果显示 .doc=Word.Document.8</span></span><br><span class="line"><span class="string">assoc .exe #显示.exe代表的&#x27;文件类型&#x27;，结果显示 .exe=exefile</span></span><br><span class="line"><span class="string">ftype #显示所有&#x27;文件类型&#x27;关联</span></span><br><span class="line"><span class="string">ftype exefile #显示exefile类型关联的命令行，结果显示 exefile=&quot;</span>%1<span class="string">&quot; %*</span></span><br><span class="line"><span class="string">assoc .txt=Word.Document.8</span></span><br><span class="line"><span class="string">设置.txt为word类型的文档，可以看到.txt文件的图标都变了</span></span><br><span class="line"><span class="string">assoc .txt=txtfile</span></span><br><span class="line"><span class="string">恢复.txt的正确关联</span></span><br><span class="line"><span class="string">ftype exefile=&quot;</span>%1<span class="string">&quot; %*</span></span><br><span class="line"><span class="string">恢复 exefile 的正确关联</span></span><br><span class="line"><span class="string">如果该关联已经被破坏，可以运行 http://command.com ，再输入这条命令</span></span><br><span class="line"><span class="string">36 pushd 和 popd</span></span><br><span class="line"><span class="string">切换当前目录</span></span><br><span class="line"><span class="string">@echo off</span></span><br><span class="line"><span class="string">c: &amp; cd &amp; md mp3 #在 C: 建立 mp3 文件夹</span></span><br><span class="line"><span class="string">md d:mp4 #在 D: 建立 mp4 文件夹</span></span><br><span class="line"><span class="string">cd /d d:mp4 #更改当前目录为 d:mp4</span></span><br><span class="line"><span class="string">pushd c:mp3 #保存当前目录，并切换当前目录为 c:mp3</span></span><br><span class="line"><span class="string">popd #恢复当前目录为刚才保存的 d:mp4</span></span><br><span class="line"><span class="string">37 for</span></span><br><span class="line"><span class="string">循环命令</span></span><br><span class="line"><span class="string">这个比较复杂，请对照 for/? 来看</span></span><br><span class="line"><span class="string">for %%i in (c: d: e: f:) do echo %%i</span></span><br><span class="line"><span class="string">依次调用小括号里的每个字符串，执行 do 后面的命令</span></span><br><span class="line"><span class="string">注意%%i，在批处理中 for 语句调用参数用2个%</span></span><br><span class="line"><span class="string">默认的字符串分隔符是&quot;</span>空格键<span class="string">&quot;，&quot;</span>Tab键<span class="string">&quot;，&quot;</span>回车键<span class="string">&quot;</span></span><br><span class="line"><span class="string">for %%i in (*.txt) do find &quot;</span>abc<span class="string">&quot; %%i</span></span><br><span class="line"><span class="string">对当前目录里所有的txt文件执行 find 命令</span></span><br><span class="line"><span class="string">for /r . %%i in (*.txt) do find &quot;</span>abc<span class="string">&quot; %%i</span></span><br><span class="line"><span class="string">在当前目录和子目录里所有的.txt文件中搜索包含 abc 字符串的行</span></span><br><span class="line"><span class="string">for /r . %%i in (.) do echo %%~pni</span></span><br><span class="line"><span class="string">显示当前目录名和所有子目录名，包括路径，不包括盘符</span></span><br><span class="line"><span class="string">for /r d:mp3 %%i in (*.mp3) do echo %%i&gt;&gt;d:mp3.txt</span></span><br><span class="line"><span class="string">把 d:mp3 及其子目录里的mp3文件的文件名都存到 d:mp3.txt 里去</span></span><br><span class="line"><span class="string">for /l %%i in (2,1,8) do echo %%i</span></span><br><span class="line"><span class="string">生成2345678的一串数字，2是数字序列的开头，8是结尾，1表示每次加1</span></span><br><span class="line"><span class="string">for /f %%i in (&#x27;set&#x27;) do echo %%i</span></span><br><span class="line"><span class="string">对 set 命令的输出结果循环调用，每行一个</span></span><br><span class="line"><span class="string">for /f &quot;</span>eol=P<span class="string">&quot; %%i in (&#x27;set&#x27;) do echo %%i</span></span><br><span class="line"><span class="string">取 set 命令的输出结果，忽略以 P 开头的那几行</span></span><br><span class="line"><span class="string">for /f %%i in (d:mp3.txt) do echo %%i</span></span><br><span class="line"><span class="string">显示 d:mp3.txt 里的每个文件名，每行一个，不支持带空格的名称</span></span><br><span class="line"><span class="string">for /f &quot;</span>delims=<span class="string">&quot; %%i in (d:mp3.txt) do echo %%i</span></span><br><span class="line"><span class="string">显示 d:mp3.txt 里的每个文件名，每行一个，支持带空格的名称</span></span><br><span class="line"><span class="string">for /f &quot;</span>skip=5 tokens=4<span class="string">&quot; %%a in (&#x27;dir&#x27;) do echo %%a</span></span><br><span class="line"><span class="string">对 dir 命令的结果，跳过前面5行，余下的每行取第4列</span></span><br><span class="line"><span class="string">每列之间的分隔符为默认的&quot;</span>空格<span class="string">&quot;</span></span><br><span class="line"><span class="string">可以注意到 dir 命令输出的前5行是没有文件名的</span></span><br><span class="line"><span class="string">for /f &quot;</span>tokens=1,2,3 delims=- <span class="string">&quot; %%a in (&#x27;date /t&#x27;) do (</span></span><br><span class="line"><span class="string">echo %%a</span></span><br><span class="line"><span class="string">echo %%b</span></span><br><span class="line"><span class="string">echo %%c</span></span><br><span class="line"><span class="string">)</span></span><br><span class="line"><span class="string">对 date /t 的输出结果，每行取1、2、3列</span></span><br><span class="line"><span class="string">第一列对应指定的 %%a ，后面的 %%b 和 %%c 是派生出来的，对应其它列</span></span><br><span class="line"><span class="string">分隔符指定为 - 和&quot;</span>空格<span class="string">&quot;，注意 delims=- 后面有个&quot;</span>空格<span class="string">&quot;</span></span><br><span class="line"><span class="string">其中 tokens=1,2,3 若用 tokens=1-3 替换，效果是一样的</span></span><br><span class="line"><span class="string">for /f &quot;</span>tokens=2* delims=- <span class="string">&quot; %%a in (&#x27;date /t&#x27;) do echo %%b</span></span><br><span class="line"><span class="string">取第2列给 %%a ，其后的列都给 %%b</span></span><br><span class="line"><span class="string">38 subst (外部命令)</span></span><br><span class="line"><span class="string">映射磁盘。</span></span><br><span class="line"><span class="string">subst z: serverd #这样输入z:就可以访问serverd了</span></span><br><span class="line"><span class="string">subst z: /d #取消该映射</span></span><br><span class="line"><span class="string">subst #显示目前所有的映时</span></span><br><span class="line"><span class="string">39 xcopy (外部命令)</span></span><br><span class="line"><span class="string">文件拷贝</span></span><br><span class="line"><span class="string">xcopy d:mp3 e:mp3 /s/e/i/y</span></span><br><span class="line"><span class="string">复制 d:mp3 文件夹、所有子文件夹和文件到 e: ，覆盖已有文件</span></span><br><span class="line"><span class="string">加 /i 表示如果 e: 没有 mp3 文件夹就自动新建一个，否则会有询问</span></span><br></pre></td></tr></table></figure>
</li>
</ul>

            <!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->
            <audio id="audio" loop="1" preload="auto" controls="controls" data-autoplay="false">
                <source type="audio/mpeg" src="">
            </audio>
            
                <ul id="audio-list" style="display:none">
                    
                        
                            <li title='0' data-url='http://link.hhtjim.com/163/1485858993.mp3'></li>
                        
                    
                </ul>
            
        </div>
        
    <div id='gitalk-container' class="comment link"
		data-enable='false'
        data-ae='false'
        data-ci=''
        data-cs=''
        data-r=''
        data-o=''
        data-a=''
        data-d='false'
    >查看评论</div>


    </div>
    
</div>


    </div>
</div>
</body>


<script src="//lib.baomitu.com/jquery/1.8.3/jquery.min.js"></script>
<script src="/js/plugin.js"></script>
<script src="/js/typed.js"></script>
<script src="/js/diaspora.js"></script>


<link rel="stylesheet" href="/photoswipe/photoswipe.css">
<link rel="stylesheet" href="/photoswipe/default-skin/default-skin.css">


<script src="/photoswipe/photoswipe.min.js"></script>
<script src="/photoswipe/photoswipe-ui-default.min.js"></script>


<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>
    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">
        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>
        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">
            <div class="pswp__top-bar">
                <!--  Controls are self-explanatory. Order can be changed. -->
                <div class="pswp__counter"></div>
                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
                <button class="pswp__button pswp__button--share" title="Share"></button>
                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>
            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>
            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>
            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>
            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>
        </div>
    </div>
</div>






</html>
